package pt.iscte.pcd.accounts;

class Account {

	private int balance;

	public Account(int value) {
		this.balance = value;
	}

	public synchronized void deposit(int amount) {
		balance += amount;
	}

	// take money out of the account if there is enough money on the account
	// returns true if the withdrawal was successful otherwise returns false.
	public synchronized boolean withdraw(int ammount) {
		if (balance >= ammount) {
			balance -= ammount;
			return true;
		}
		return false;
	}

	int getBalance() { // get the current balance of the account
		return balance;
	}
}